<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BoookingDetails
 *
 * @author fabiano
 */
class BoookingDetails {
    //put your code here
    public $booking_detail_id;
    public $booking_id;
    public $check_in_date;
    public $check_out_date;
    public $num_night;
    public $customer_tittle;
    public $customer_first_name;
    public $customer_last_name;
    public $customer_email;
    public $customer_phone;
    public $num_room;
    public $status;    
    public $supplier_hotel_id;


        
    function __construct($params = null) {
        if ($params != null) {
            $this->setBooking_id($params['booking_id']);
            $this->setCheck_in_date($params['check_in_date']);
            $this->setCheck_out_date($params['check_out_date']);
            $this->setCustomer_email($params['customer_email']);
            $this->setCustomer_phone($params['customer_phone']);
            $this->setCustomer_tittle($params['customer_tittle']);
            $this->setNum_night($params['num_night']);
            $this->setNum_room($params['num_room']);
            $this->setCustomer_first_name($params['customer_first_name']);
            $this->setCustomer_last_name($params['customer_last_name']);
            $this->setSupplier_hotel_id($params['supplier_hotel_id']);
            $this->setStatus(0);
        }
        
    }
    
    
    public function getSupplier_hotel_id() {
        return $this->supplier_hotel_id;
    }

    public function setSupplier_hotel_id($supplier_hotel_id) {
        $this->supplier_hotel_id = $supplier_hotel_id;
    }
    
    public function getBooking_detail_id() {
        return $this->booking_detail_id;
    }

    public function setBooking_detail_id($booking_detail_id) {
        $this->booking_detail_id = $booking_detail_id;
    }

    public function getBooking_id() {
        return $this->booking_id;
    }

    public function setBooking_id($booking_id) {
        $this->booking_id = $booking_id;
    }

    public function getCheck_in_date() {
        return $this->check_in_date;
    }

    public function setCheck_in_date($check_in_date) {
        $this->check_in_date = $check_in_date;
    }

    public function getCheck_out_date() {
        return $this->check_out_date;
    }

    public function setCheck_out_date($check_out_date) {
        $this->check_out_date = $check_out_date;
    }

    public function getNum_night() {
        return $this->num_night;
    }

    public function setNum_night($num_night) {
        $this->num_night = $num_night;
    }

    public function getCustomer_tittle() {
        return $this->customer_tittle;
    }

    public function setCustomer_tittle($customer_tittle) {
        $this->customer_tittle = $customer_tittle;
    }

    public function getCustomer_first_name() {
        return $this->customer_first_name;
    }

    public function setCustomer_first_name($customer_first_name) {
        $this->customer_first_name = $customer_first_name;
    }

    public function getCustomer_last_name() {
        return $this->customer_last_name;
    }

    public function setCustomer_last_name($customer_last_name) {
        $this->customer_last_name = $customer_last_name;
    }

    public function getCustomer_email() {
        return $this->customer_email;
    }

    public function setCustomer_email($customer_email) {
        $this->customer_email = $customer_email;
    }

    public function getCustomer_phone() {
        return $this->customer_phone;
    }

    public function setCustomer_phone($customer_phone) {
        $this->customer_phone = $customer_phone;
    }

    public function getCustomer_phone_1() {
        return $this->customer_phone;
    }

    public function setCustomer_phone_1($customer_phone) {
        $this->customer_phone = $customer_phone;
    }

    public function getNum_room() {
        return $this->num_room;
    }

    public function setNum_room($num_room) {
        $this->num_room = $num_room;
    }

    public function getStatus() {
        return $this->status;
    }

    public function setStatus($status) {
        $this->status = $status;
    }
    
    public function save(){
      //  $params = new ArrayObject($this);
        //        print_r($params); die();
        $sql = "INSERT INTO booking_details SET ".make_set_clause(objectToArray($this));  
        error_log("[BookingDetails.class] - save " .$sql);
        $result = mysql_query($sql) or die (mysql_error());
        $this->booking_detail_id = mysql_insert_id();   
        
    }
    
    public function get_details_by_booking_id($id){
	if(!empty($id)){		
	   $sql = "SELECT * FROM BOOKING_DETAILS where  booking_detail_id = ".$id;			
	   return apply_query($sql);
        } 
          else return null;
    }
    
    public function get_booking_with_details_by_booking_id($id){
	if(!empty($id)){		
	   $sql = "select *
                   from 
                       bookings b
                       join booking_details d
                       on b.booking_id = d.booking_id 
                       join booking_payment bp
                       on bp.booking_id = b.booking_id
                   where  b.booking_id = ".$id;	
           error_log("query: ".$sql);
	   return apply_query($sql);
        } 
          else return null;        
    }


            
            
}

?>
